

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:huajianshe_app/base/AppNavigator.dart';
import 'package:huajianshe_app/common/C.dart';
import 'package:huajianshe_app/common/space.dart';
import 'package:huajianshe_app/widget/SmartButton.dart';

class SelectMediaBottomSheet extends StatelessWidget {

  final bool includeVideo; //是否需要'拍视频'、'从相册中选择视频'的菜单
  final Function(bool isVideo, bool isCamera) onMediaResult;
  SelectMediaBottomSheet({this.includeVideo = false, this.onMediaResult = _onMediaResult});

  static _onMediaResult(bool isVideo, bool isCamera) {}

  @override
  Widget build(BuildContext context) {
    return
      
          Column(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.start,
            children: <Widget>[
              SmartButton(
                height: 54.0,
                width: double.infinity,
                textColor: C.primary,
                text: '拍照',
                fontSize: 17,
                borderColor: Colors.transparent,
                backgroundColor: Colors.transparent,
                onPressed: () {
                  AppNavigator.pop(context);
                  onMediaResult(false, true);
                },
              ),
              D(),
              SmartButton(
                height: 54.0,
                width: double.infinity,
                textColor:C.primary,
                text: '从相册选图片',
                fontSize:  17,
                backgroundColor: Colors.transparent,
                borderColor: Colors.transparent,
                onPressed: () {
                  AppNavigator.pop(context);
                  onMediaResult(false, false);
                },
              ),
              D(),

              ...buildVideo(context),
              SmartButton(
                height: 54.0,
                width: double.infinity,
                textColor: Color(0xff353535),
                text: '取消',
                fontSize: 15,
                backgroundColor: Colors.transparent,
                borderColor: Colors.transparent,
                onPressed: () {
                  AppNavigator.pop(context);
                },
              ),
            ],
          )



    ;
  }

  List<Widget> buildVideo(BuildContext context) {
    if (includeVideo) {
      return [
        SmartButton(
          height: 54.0,
          width: double.infinity,
          textColor: C.primary,
          text: '拍视频',
          fontSize: 17,
          backgroundColor: Colors.transparent,
          borderColor: Colors.transparent,
          onPressed: () {
            AppNavigator.pop(context);
            onMediaResult(true, true);
          },
        ),
        D(),
        SmartButton(
          height: 54.0,
          width: double.infinity,
          textColor: C.primary,
          text: '从相册选视频',
          fontSize: 17,
          backgroundColor: Colors.transparent,
          borderColor: Colors.transparent,
          onPressed: () {
            AppNavigator.pop(context);
            onMediaResult(true, false);
          },
        ),
        D()
      ];
    } else {
      return [];
    }
  }

}